#include "stdafx.h"
#include "GameStateMgr.h"
#include "QueueBattle.h"
#include "Factory.h"
#include "wowfun.h"

CQueueBattle::CQueueBattle()
{
    Name = _T("CQueueBattle");
}

CQueueBattle::~CQueueBattle()
{
}

void CQueueBattle::PromoteToPartyLeader()
{
    CPlayer& Player = *IFactory::getSingleton().GetPlayer();
    Player.EndMoving();
    if (CWowFun::IsPartyLeader(Player.GetGuid()))
    {
        CWowFun::KeyDown(VK_F2);
        CWowFun::KeyUp(VK_F2);
        CWowFun::ExecuteScript("/run PromoteToLeader(\"target\")");
        sMyTime::Instance().Sleep(2000);
    }
}

void CQueueBattle::Reset()
{

}

void CQueueBattle::DoAction()
{
    CPlayer& Player = *IFactory::getSingleton().GetPlayer();
    if (Player.IsCasting() || Player.IsChannel()) return;

    if (Player.HasBuf(44521))
    {
        PromoteToPartyLeader();
    }
    else
    {
        sMyTime::Instance().Sleep(5000);
    }
}